#ifndef _LOGGER_H_
#define _LOGGER_H_

#include <stdio.h>

typedef enum 
    {
        LOG_NONE,
        LOG_INFO,
        LOG_DEBUG,
        LOG_ERROR,
        LOG_FATAL
    }log_level_t;
        
typedef struct logger_setting
{
    FILE *filp;
    log_level_t level;
    int (*log_writer)(struct logger_setting *, log_level_t , const char *fname, const int line, const char *func, const char *fmt, ...);
}logger_setting_t;

typedef int (*fn_log_writer)(logger_setting_t *, log_level_t, const char *fname, const int line, const char *func, const char *fmt, ...);

logger_setting_t *get_default_logger();
void free_default_logger();

logger_setting_t *logger_setting_init(const char *fn, log_level_t level, fn_log_writer);
logger_setting_t *logger_setting_init_fp(FILE *fp, log_level_t level, fn_log_writer);
void logger_setting_free(logger_setting_t *pls);

extern logger_setting_t *g_logger;

#define LOGGER_NONE(fmt, args...) 
#define LOGGER_INFO(fmt, args...) g_logger->log_writer(g_logger, LOG_INFO, __FILE__, __LINE__, __func__, fmt, ##args)
#define LOGGER_DEBUG(fmt, args...) g_logger->log_writer(g_logger, LOG_DEBUG, __FILE__, __LINE__, __func__, fmt, ##args)
#define LOGGER_ERROR(fmt, args...) g_logger->log_writer(g_logger, LOG_ERROR, __FILE__, __LINE__, __func__, fmt, ##args)
#define LOGGER_FATAL(fmt, args...) g_logger->log_writer(g_logger, LOG_FATAL, __FILE__, __LINE__, __func__, fmt, ##args)

#endif // End _LOGGER_H_








